- page_title @project.name_with_namespace, "项目"
%h3.page-title
  项目：#{@project.name_with_namespace}
  = link_to edit_project_path(@project), class: "btn btn-nr pull-right" do
    %i.fa.fa-pencil-square-o
    编辑
%hr
- if @project.last_repository_check_failed?
  .row
    .col-md-12
      .panel
        .panel-heading.alert.alert-danger
          最后一次版本仓库检查
          = "(#{time_ago_in_words(@project.last_repository_check_at)} 之前)"
          失败. 查看
          = link_to 'repocheck.log', admin_logs_path
          获取错误信息。
.row
  .col-md-6
    .panel.panel-default
      .panel-heading
        项目信息：
      %ul.well-list
        %li
          %span.light 名称：
          %strong
            = link_to @project.name, project_path(@project)
        %li
          %span.light 命名空间：
          %strong
            - if @project.namespace
              = link_to @project.namespace.human_name, [:admin, @project.group || @project.owner]
            - else
              全局
        %li
          %span.light 拥有者：
          %strong
            - if @project.owner
              = link_to @project.owner_name, [:admin, @project.owner]
            - else
              (已删除)

        %li
          %span.light 创建者：
          %strong
            = @project.creator.try(:name) || '(已删除)'

        %li
          %span.light 创建时间：
          %strong
            = @project.created_at.to_s(:medium)

        %li
          %span.light http:
          %strong
            = link_to @project.http_url_to_repo, project_path(@project)
        %li
          %span.light ssh:
          %strong
            = link_to @project.ssh_url_to_repo, project_path(@project)
        - if @project.repository.exists?
          %li
            %span.light 文件系统：
            %strong
              = @project.repository.path_to_repo

          %li
            %span.light 大小
            %strong
              = repository_size(@project)

          %li
            %span.light 最后提交：
            %strong
              = last_commit(@project)
        - else
          %li
            %span.light 版本库：
            %strong.cred
              不存在

        - if @project.archived?
          %li
            %span.light 已归档：
            %strong 版本库只读

        %li
          %span.light 访问：
          %strong
            %span{ class: visibility_level_color(@project.visibility_level) }
              = visibility_level_icon(@project.visibility_level)
              = visibility_level_label(@project.visibility_level)

    .panel.panel-default
      .panel-heading
        转移项目
      .panel-body
        = form_for @project, url: transfer_admin_namespace_project_path(@project.namespace, @project), method: :put, html: { class: 'form-horizontal' } do |f|
          .form-group
            = f.label :new_namespace_id, "命名空间", class: 'control-label'
            .col-sm-10
              = namespace_select_tag :new_namespace_id, selected: params[:namespace_id], class: 'input-large'

          .form-group
            .col-sm-offset-2.col-sm-10
              = f.submit '转移', class: 'btn btn-primary'

    .panel.panel-default.repository-check
      .panel-heading
        版本仓库检查
      .panel-body
        = form_for @project, url: repository_check_admin_namespace_project_path(@project.namespace, @project), method: :post do |f|
          .form-group
            - if @project.last_repository_check_at.nil?
              此版本仓库还未被检查过。
            - else
              此版本仓库最后检查时间在
              = @project.last_repository_check_at.to_s(:medium) + '。'
              该检查
              - if @project.last_repository_check_failed?
                = succeed '。' do
                  %strong.cred 失败
                查看
                = link_to 'repocheck.log', admin_logs_path
                获取错误信息。
              - else
                正常。

            = link_to icon('question-circle'), help_page_path('administration', 'repository_checks')

          .form-group
            = f.submit '触发版本仓库检查', class: 'btn btn-primary'

  .col-md-6
    - if @group
      .panel.panel-default
        .panel-heading
          %strong #{@group.name}
          群组成员 (#{@group.group_members.count})
          .pull-right
            = link_to admin_group_path(@group), class: 'btn btn-xs' do
              %i.fa.fa-pencil-square-o
        %ul.well-list
          - @group_members.each do |member|
            = render 'groups/group_members/group_member', member: member, show_controls: false
        .panel-footer
          = paginate @group_members, param_name: 'group_members_page', theme: 'gitlab'

    .panel.panel-default
      .panel-heading
        项目成员
        %small
          (#{@project.users.count})
        .pull-right
          = link_to namespace_project_project_members_path(@project.namespace, @project), class: "btn btn-xs" do
            %i.fa.fa-pencil-square-o
            管理权限
      %ul.well-list.project_members
        - @project_members.each do |project_member|
          - user = project_member.user
          %li.project_member
            .list-item-name
              - if user
                %strong
                  = link_to user.name, admin_user_path(user)
              - else
                %strong
                  = project_member.invite_email
                (invited)
            .pull-right
              - if project_member.owner?
                %span.light 拥有者
              - else
                %span.light= project_member.human_access
                = link_to namespace_project_project_member_path(@project.namespace, @project, project_member), data: { confirm: remove_from_project_team_message(@project, project_member)}, method: :delete, remote: true, class: "btn btn-sm btn-remove" do
                  %i.fa.fa-times
      .panel-footer
        = paginate @project_members, param_name: 'project_members_page', theme: 'gitlab'
